package com.itheima.controller.user;

import com.itheima.DTO.IndexNewDTO;
import com.itheima.DTO.LoginDTO;
import com.itheima.DTO.UserYddArticlePageDTO;
import com.itheima.VO.*;
import com.itheima.result.Result;
import com.itheima.service.IndexService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;


@RestController
@Slf4j
@RequestMapping("/index")
@RequiredArgsConstructor
public class UserIndexController {

    private final IndexService indexService;

    @GetMapping("/index")
    public Result<?> index(){
        IndexVO indexVO = indexService.selectAll();
        return Result.success(indexVO);
    }

    @GetMapping("/new")
    public Result<?> hotArticle(IndexNewDTO indexNewDTO){
        HotArticleVO hotArticleVO = indexService.selectHotArticle(indexNewDTO.getPage(),indexNewDTO.getLimit());
        return Result.success(hotArticleVO);
    }

    @GetMapping("/hot")
    public Result<?> newArticle(){
        NewArticleVO newArticleVO = indexService.selectNewArticle();
        return Result.success(newArticleVO);
    }

    @GetMapping("/recommend")
    public Result<?> recommend(){
        RecommendArticleVO recommendArticleVO = indexService.selectRecommendArticle();
        return Result.success(recommendArticleVO);
    }

    @GetMapping("/list")
    public Result<?> list(UserYddArticlePageDTO userYddArticlePageDTO){
        InsertPageVO insertPageVO = indexService.page(userYddArticlePageDTO);
        return Result.success(insertPageVO);
    }

    @GetMapping("/show")
    public Result<?> ArticleShow(Integer id){
        YddArticleShowVO yddArticleShowVO = indexService.selectArticeleInfoById(id);
        return Result.success(yddArticleShowVO);
    }
}




